package com.hopital5.zhangyz.controller

import com.hopital5.zhangyz.BaseTest
import com.hopital5.zhangyz.model.Activity
import com.hopital5.zhangyz.model.ActivityActivityItem
import com.hopital5.zhangyz.model.ActivityItem
import com.hopital5.zhangyz.model.Label
import com.hopital5.zhangyz.model.People
import com.hopital5.zhangyz.repository.ActivityItemRepository
import com.hopital5.zhangyz.repository.ActivityRepository
import com.hopital5.zhangyz.repository.LabelRepository
import com.hopital5.zhangyz.repository.PeopleRepository
import com.hopital5.zhangyz.service.ActivityService
import com.hopital5.zhangyz.vo.enums.PeopleSex
import com.hopital5.zhangyz.vo.request.ActivityActivityItemVoRequest
import com.hopital5.zhangyz.vo.request.ActivityItemVoRequest
import com.hopital5.zhangyz.vo.request.ActivityVoRequest
import com.hopital5.zhangyz.vo.request.LabelVoRequest
import com.hopital5.zhangyz.vo.request.PeopleVoRequest
import com.hopital5.zhangyz.vo.response.ActivityItemVoResponse
import com.hopital5.zhangyz.vo.response.ActivityVoResponse
import com.hopital5.zhangyz.vo.response.LabelVoResponse
import com.hopital5.zhangyz.vo.response.PeopleVoResponse
import org.junit.Test
import org.springframework.beans.factory.annotation.Autowired

class ActivityControllerTest extends BaseTest {
    @Autowired
    ActivityRepository activityRepository
    @Autowired
    ActivityService activityService
    @Autowired
    ActivityController activityController
    @Autowired
    PeopleRepository peopleRepository
    @Autowired
    LabelRepository labelRepository;
    @Autowired
    LabelController labelController
    @Autowired
    ActivityItemRepository activityItemRepository
    @Autowired
    PeopleController peopleController
    @Autowired
    ActivityItemController activityItemController
    @Autowired
    ActivityActivityItemController activityActivityItemController

    @Autowired

    @Test
    void test() {
        LabelVoRequest labelVoRequest = new LabelVoRequest(name: "东电幼儿园小一班")
        LabelVoResponse labelVoResponse = labelController.insert(labelVoRequest)
        PeopleVoResponse peopleVoResponse = peopleController.insert(new PeopleVoRequest(name: "张志睿", peopleSex: PeopleSex.MAN, number: 35, labelIds: [labelVoResponse.id]))
        PeopleVoResponse peopleVoResponse1 = peopleController.insert(new PeopleVoRequest(name: "刘楚萌", peopleSex: PeopleSex.WOMAN, number: 8, labelIds: [labelVoResponse.id]))
        ActivityItemVoResponse activityItemVoResponse = activityItemController.insert(new ActivityItemVoRequest(name: "胶布", unit: "个"))
        ActivityItemVoResponse activityItemVoResponse1 = activityItemController.insert(new ActivityItemVoRequest(name: "口哨", unit: "个"))
        ActivityVoResponse activityVoResponse = activityController.insert(new ActivityVoRequest(beginDate: new Date(), endDate: new Date(), name: '团购炼焦', labelId: labelVoResponse.getId(), activityItemIds: [activityItemVoResponse.id, activityItemVoResponse1.id]))
        activityActivityItemController.update([
                new ActivityActivityItemVoRequest(activityId: activityVoResponse.getId(), activityItemId: activityItemVoResponse.id, peopleId: peopleVoResponse.id, number: 1, numberOld: 0),
                new ActivityActivityItemVoRequest(activityId: activityVoResponse.getId(), activityItemId: activityItemVoResponse1.id, peopleId: peopleVoResponse.id, number: 2, numberOld: 0),
                new ActivityActivityItemVoRequest(activityId: activityVoResponse.getId(), activityItemId: activityItemVoResponse.id, peopleId: peopleVoResponse1.id, number: 3, numberOld: 0),
                new ActivityActivityItemVoRequest(activityId: activityVoResponse.getId(), activityItemId: activityItemVoResponse1.id, peopleId: peopleVoResponse1.id, number: 4, numberOld: 0),
        ])
        jsonOutPut activityController.detail(activityVoResponse.id)
    }
}
